﻿
@using LERP.Domain.Enums
@using LERP.Web.App_Start
@using Sharp.Framework
@using Sharp.Framework.Extensions

@model MvcContrib.Pagination.IPagination<LERP.Web.Controllers.ViewModels.UserViewModels.UserViewModel>
@{
    ViewBag.Title = "员工列表";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
 
            @using (Html.BeginForm("Index", "User", FormMethod.Get))
            {
                <table class="table_input" style="width: 100%;">
                    <tr>
                           <th style="width: 80px;">角色:</th>
                         <td style="width: 150px;">@Html.DropDownList("role", (ViewBag.Roles as List<SelectListItem>).InsertEmpty(), new { @class = "text-medium", style = "width: 99%;" })</td>
                       <th style="width: 80px;">关键字:</th>
                        <td style="width: 150px;">@Html.TextBox("keyword", "", new { @class = "text-medium", style = "width: 80%;" })</td>
                        <td>
                            <input type="submit" class="button-submit" value="查询" />
                            @Html.ActionLinkEx("新建","Create","User",new {  returnUrl = Request.RawUrl}, new { })</td>
                    </tr>
                </table>
            }
            @if (Model != null && Model.Any())
            {
                <table class="table_list" style="width: 99%;">
                    <tr>
                        <th style="width: 60px;">员工编码</th>
                        <th>登录名</th>
                        <th style="width: 80px;">姓名</th> 
                        <th style="width: 50px;">角色</th> 
                        <th style="width: 80px;">手机</th>
                        <th style="width: 180px;">邮箱</th>
                        <th style="width: 120px;">操作</th>
                    </tr>
                    @foreach (var item in Model)
                    {
                        <tr>
                            <td>@item.Id 
                            </td>
                            <td>@item.UserName</td>
                            <td>@item.Name</td> 
                            <td>@(((UserRole)item.Role).GetDescription())</td> 
                            
                            <td>@item.Mobile</td>
                            <td>@item.Email</td>
                            <td class="action">    
                                @Html.ActionLinkEx("修改", "Edit", "User", new {id = item.Id, returnUrl = Request.RawUrl}, new {@class = ""}) 
                              
                                @Html.ActionLinkEx("重置密码", "ResetPassword", "User", new {id = item.Id, returnUrl = Request.RawUrl}, new {@class = ""}) 
                              
                                @Html.ActionLinkEx("删除", "Delete", "User", new {id = item.Id, returnUrl = Request.RawUrl}, new {@class = "delete"})
                             
                            </td>
                        </tr>
                    }


                </table>
    
                <div class="page">
                    @Html.Pager("page", Model.PageSize, Model.TotalItems)
                </div>
            }
            else
            {
                <div class="empty">
                    查询信息为空
                </div>
            }
       @section Scripts {
    <script type="text/javascript">

        $(function () {
            $("a.delete").click(function () {
                return window.confirm("您确认要"+$(this).html()+"当前员工么?");

            });

        })

    </script>

}
